<template>
  <div>
    <zh-form  :span="8" ref="formInfo" :colmun="1"  :labelCol="labelColBase"
              :wrapperCol="wrapperColBase" :rules="rules" :model="formInfo"  labelAlign="right" >

      <zh-card title="基本信息" style="width:100%">
        <zh-row>
          <zh-input
              prop="h2202"
              type="text"
              label="责任部门"
              v-model="formInfo.h2202"
          ></zh-input>
          <zh-input
              prop="h2203"
              type="text"
              label="职任"
              v-model="formInfo.h2203"
          ></zh-input>
          <zh-input
              prop="h2205"
              type="text"
              label="责任人"
              v-model="formInfo.h2205"
          ></zh-input>
          <zh-input
              prop="h2206"
              type="text"
              label="浙政钉ID"
              v-model="formInfo.h2206"
          ></zh-input>
        </zh-row>
      </zh-card>
    </zh-form>
  </div>
</template>

<script>
import modal from 'ant-design-vue/es/modal'
import {getBatchDict} from "@/services/system/api"
import {emergencyAdd,getEmergencyDetails} from '@/services/system/whdngxlApi'
import {TreeSelect} from "ant-design-vue";
import moment from "moment";
import {mapGetters} from "vuex";

const SHOW_PARENT = TreeSelect.SHOW_PARENT;
export default {
  name: "emergencyAddForm",
  components:{
  },
  computed: {
    ...mapGetters(['size']),
  },
  props:{
    listQuery:{
      type:Function,
      default:null
    },
  },
  data() {
    return {
      toolbarConfig: {
        slots: {
          tools: 'toolbar_tools'
        }
      },
      formInfo:{
        h2201:'',
        h2202:'',
        h2203:'',
        h2205:'',
        h2206:'',
      },
      rules:{},
      taskAreaTree:[],
      SHOW_PARENT,
      labelCol: { span: 2 },
      wrapperCol: { span: 22 },
      labelColBase: {
        xs: {span: 24},
        sm: {span: 8},
      },
      wrapperColBase: {
        xs: {span: 24},
        sm: {span: 16},
      },
      tableType:'1',
    }
  },

  created() {
  /*  const params2 = {};
    params2.dictFields = "xzqh,b0106";
    this.$http.post(getBatchDict, params2).then((res) => {
      this.dictData = res.result;
    });*/
  },
  methods: {
    initData(data){
      //编辑
      if(data.h2201){
        const params = {}
        params.h2201 = data.h2201
        params.tableType = this.tableType
        setTimeout(() => {
          this.$http.post(getEmergencyDetails, params).then((res) => {
              this.formInfo = res.result
          }).catch((error) => {
          }).finally(() =>{
          })
        }, 50)
      }
    },
    confirm(){
      if(this.formInfo.h2205 == '' || this.formInfo.h2205 == null ){
        modal.warn({ title: "提示", content: "责任人不能为空" });
        return;
      }
      this.$loading.show('正在处理数据,请等待...')
      const params = Object.assign(this.formInfo)
      params.tableType = this.tableType
      setTimeout(() => {
        this.$http.post(emergencyAdd, params).then((res) => {
          this.$message.info('保存成功')
            this.$emit("handleCancel")
            if(this.listQuery) {
              this.listQuery()
            }
        }).catch((error) => {
          console.log(JSON.stringify(error))
        }).finally(() =>{
          this.$loading.hide()
        })
      }, 50)
    },
  }
}
</script>

<style scoped lang="less">
.list-item {
  display: flex;

  .list-item-index {
    width: 36px;
    font-size: 18px;
  }
}

.sub-form {
  margin-top: 15px;
}
</style>
